package lab2;


import lab3.XMLReadUtil;

//财务部
public class FDVisitor implements VisitorInterface{

    public FDVisitor(){}
    @Override
    public void visit(RegularStaff regularStaff) {
        //System.out.println(regularStaff.getName()+"‘s salary is "+SalaryReference.getSalary(regularStaff));
        double baseSalary = ReadSalaryUtil.getSalary(String.valueOf(regularStaff.getDepartment()),"BaseSalary");
        double extraSalary = ReadSalaryUtil.getSalary(String.valueOf(regularStaff.getLevel()), "ExtraSalary");
        double tmpSalary = baseSalary+extraSalary;
        int hours = regularStaff.getHours();
        if (hours < 40){
            tmpSalary = Math.min(tmpSalary-(40-hours)*80.0,0);
        }else {
            tmpSalary = tmpSalary + (hours - 40)*100.0;
        }
        System.out.println(regularStaff.getName()+"‘s salary is "+tmpSalary);
    }

    @Override
    public void visit(Intern intern) {
        //System.out.println(intern.getName()+"‘s salary is "+SalaryReference.getSalary(intern));
        double salary = ReadSalaryUtil.getSalary(String.valueOf(intern.getDepartment()), "InternSalary");
        System.out.println(intern.getName()+"‘s salary is "+intern.getHours()* salary);
    }
}
